package com.audi.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;

import com.audi.R;

public class TutorialViewPagerAdapter extends PagerAdapter {

    private Context mContext;
    private int mPageTutorial = 4;

    public TutorialViewPagerAdapter(Context context) {
	mContext = context;
    }

    @Override
    public void destroyItem(View container, int position, Object objectTutorial) {
	((ViewPager) container).removeView((View) objectTutorial);
    }

    @Override
    public int getCount() {
	return mPageTutorial;
    }

    @Override
    public boolean isViewFromObject(View argTutorialiew, Object argTutorial) {
	return argTutorialiew == ((View) argTutorial);
    }

    @SuppressLint("InflateParams")
    @Override
    public Object instantiateItem(View containerTutorialiew, int positionTutorial) {
	View iv = null;
	switch (positionTutorial) {
	case 0:
	    iv = LayoutInflater.from(mContext).inflate(
		    R.layout.tutorial_page_1, null);
	    break;
	case 1:
	    iv = LayoutInflater.from(mContext).inflate(
		    R.layout.tutorial_page_2, null);
	    break;
	case 2:
	    iv = LayoutInflater.from(mContext).inflate(
		    R.layout.tutorial_page_3, null);
	    break;
	case 3:
	default:
	    iv = LayoutInflater.from(mContext).inflate(
		    R.layout.tutorial_page_4, null);
	    break;
	}
	iv.setTag(positionTutorial);
	((ViewPager) containerTutorialiew).addView(iv);
	return iv;
    }

}
